$(function(){
    $(".confirm").click(function(){
        let users = localStorage.getItem("users");
        if (users) {
            users = JSON.parse(users);
            let user = users.some(user => user.user == $("#user").val() && user.pass == $("#pass").val());
            if (user) {
                // localStorage.setItem("remUser","");
                let loginUser = {
                    user: $("#user").val(),
                    pass: $("#pass").val()
                }
                localStorage.setItem("loginUser",JSON.stringify(loginUser));
                alert("登录成功");
                location.assign("../html/home.html");
            }else{
                alert("用户名或密码错误");
            }
        }else{
            alert("请先注册")
        }
    });
    $("#eye").click(function(){
        if ($(this).attr("class").substr(9) == "icon-biyan") {
            $(this).removeClass("icon-biyan").addClass("icon-yanjing");
            $("#pass").prop("type","text");
        }else{
            $(this).removeClass("icon-yanjing").addClass("icon-biyan");
            $("#pass").prop("type","password");
        }
    });
});